package com.example.demo.service.Impl;

import com.example.demo.dao.ILqmana;
import com.example.demo.model.Lqmana;
import com.example.demo.service.ILqmanaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Service
public class LqmanaServiceImpl implements ILqmanaService {

    @Autowired
    private ILqmana lqmanaMapper;
    @Override
    public int insertLqmana(Lqmana lqmana){
        int lqmanaValue=0;

        Lqmana lqmana1=new Lqmana();
        lqmana1.setLbid(lqmana.getLbid());
        List<Lqmana> getL=lqmanaMapper.getAllLqmana(lqmana1);
        if(getL.size()>0){
            lqmanaValue=-1;

        }else{
            lqmanaValue=lqmanaMapper.insertLqmana(lqmana);
        }

        return lqmanaValue;
    }

    @Override
    public List<Lqmana> getAllLqmana(Lqmana lqmana) {


        return lqmanaMapper.getAllLqmana(lqmana);
    }

    @Override
    public int updateLqmana(Lqmana lqmana) {
        int lqmanaValues=0;
        if(lqmana.getLbid()!=0){
            lqmanaValues=lqmanaMapper.updateLqmana(lqmana);
        }
        return lqmanaValues;
    }

    @Override
    public int deleteLqmana(Lqmana lqmana) {
        int lqmanaValues=0;
        if(lqmana.getLbid()!=0)
        {
            //主键是否与其他表有关联

            lqmanaValues=lqmanaMapper.deleteLqmana(lqmana);
        }
        return lqmanaValues;
    }

    @Override
    public Lqmana getLqmana(Lqmana lqmana) {
        Lqmana lqmana1=new Lqmana();
        if(lqmana.getLbid()!=0){
            lqmana1=lqmanaMapper.getLqmana(lqmana);
        }
        return lqmana1;
    }

}
